←Select platform

RemapHueCommand Constructor(int[],int[],int[],int[],int)

Summary
Initializes a new RemapHueCommand class object with explicit parameters.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public RemapHueCommand( 
   int[] mask, 
   int[] hueTable, 
   int[] saturationTable, 
   int[] valueTable, 
   int lookUpTableLength 
) 
- (instancetype)initWithMask:(nullable const unsigned int *)mask hueTable:(nullable const unsigned int *)hueTable saturationTable:(nullable const unsigned int *)saturationTable valueTable:(nullable const unsigned int *)valueTable lookUpTableLength:(NSUInteger)lookUpTableLength NS_DESIGNATED_INITIALIZER; 
public RemapHueCommand( 
   int[] mask, 
   int[] hueTable, 
   int[] saturationTable, 
   int[] valueTable, 
   int lookUpTableLength 
); 
public: 
RemapHueCommand(  
   array<int>^ mask, 
   array<int>^ hueTable, 
   array<int>^ saturationTable, 
   array<int>^ valueTable, 
   int lookUpTableLength 
) 
__init__(self,mask,hueTable,saturationTable,valueTable,lookUpTableLength) # Overloaded constructor 

Parameters

mask
Lookup table that identifies which values in the hueTable, saturationTable and valueTable are valid. If Mask[i] is non-zero, then hueTable, saturationTable and valueTable are to be used. If Mask[i] is 0 then hueTable, saturationTable and valueTable are ignored. If Mask is null, all entries in the hueTable, saturationTable and valueTable are used.

hueTable
Hue look up table. If the Mask table value for a particular pixel hue is non-zero, then the hue is changed to the corresponding entry in hueTable. For example, if a pixel value has a hue of 85 and Mask[85] is non-zero, the hue is changed to hueTable[85]. If hueTable is null, the hue of each pixel is unchanged.

saturationTable
Saturation look up table. If the Mask table value for a particular pixel hue is non-zero, then the saturation is changed to the corresponding entry in saturationTable. For example, if a pixel value has a hue of 85 and Mask[85] is non-zero, the saturation is changed to saturationTable[85]. If hueTable is null, the saturation is changed to saturationTable[85]. If saturationTable is null, the saturation of each pixel is unchanged.

valueTable
Value look up table. If the Mask table value for a particular pixel hue is non-zero, then the value is changed to the corresponding entry in valueTable. For example, if a pixel value has a hue of 85 and Mask[85] is non-zero, the value is changed to valueTable[85]. If hueTable is null, the value is changed to ValueTable[85]. If valueTable is null, the value of each pixel is unchanged.

lookUpTableLength
Length of the lookup table. Possible values are 65536 for 16-bit image, 4096 for 12-bit image, 256 for 8-bit image

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Color; 
 
 
public int INCREMENT_S1(int x, int Length) 
{ 
   return ((x + 1) % Length); 
} 
 
public int DECREMENT_S1(int x, int Length) 
{ 
   return ((x + (Length - 1)) % Length); 
} 
 
public int ADD_S1(int x, int y, int Length) 
{ 
   return ((x + y) % Length); 
} 
 
public void RemapHueCommandCommandExample() 
{ 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg")); 
 
   // Prepare the command 
   int[] MaskTable; 
   int[] HueTable; 
   RasterHsvColor hsvRef; 
   int HueGreen, HueChange; 
   int Change; 
   int i, Count; 
   int Length; 
 
   if (image.BitsPerPixel >= 48) 
      Length = 0x10000; 
   else if (!(image.BitsPerPixel == 16 || image.BitsPerPixel == 12)) 
      Length = 256; 
   else if (image.GetLookupTable() != null && image.UseLookupTable) 
      Length = 256; 
   else 
      Length = (1 << image.BitsPerPixel); 
 
   //Allocate tables 
   MaskTable = new int[Length]; 
   HueTable = new int[Length]; 
 
   //Initialize tables 
   for (i = 0; i < Length; i++) 
   { 
      MaskTable[i] = 0; 
      HueTable[i] = i; 
   } 
 
   //Get the hue for green 
   hsvRef = RasterHsvColor.FromRasterColor(new RasterColor(0, 255, 0)); 
 
   HueGreen = hsvRef.H; 
 
   //Obtain new hue   
   hsvRef = RasterHsvColor.FromRasterColor(new RasterColor(255, 128, 0)); 
   Change = (int)hsvRef.H - (int)HueGreen; 
   HueChange = (Change > 0) ? (int)Change : (int)(Change + Length - 1); 
   HueGreen *= (Length - 1) / 255; 
   HueChange *= (Length - 1) / 255; 
 
   //Set values in HueTable, MaskTable  
   HueTable[HueGreen] = (HueTable[HueGreen] + HueChange); 
   MaskTable[HueGreen] = 1; 
 
   //set the hues near green (+/- 15) 
   Count = (15 * (Length - 1)) / 255; 
   for (i = INCREMENT_S1(HueGreen, Length); Count > 0; i = INCREMENT_S1(i, Length), Count--) 
   { 
      HueTable[i] = ADD_S1(HueTable[i], HueChange, Length); 
      MaskTable[i] = 1; 
   } 
 
   Count = (15 * (Length - 1)) / 255; 
   for (i = DECREMENT_S1(HueGreen, Length); Count > 0; i = DECREMENT_S1(i, Length), Count--) 
   { 
      HueTable[i] = ADD_S1(HueTable[i], HueChange, Length); 
      MaskTable[i] = 1; 
   } 
 
   RemapHueCommand command = new RemapHueCommand(MaskTable, HueTable, null, null, Length); 
   command.Run(image); 
   codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "Result.jpg"), RasterImageFormat.Jpeg, 24); 
 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.3.31
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.ImageProcessing.Color Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.